package com.holic.spring.graphql.controller;

import com.holic.spring.graphql.entity.Project;
import com.holic.spring.graphql.entity.ProjectStatus;
import com.holic.spring.graphql.entity.User;
import org.springframework.graphql.data.method.annotation.Argument;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.stereotype.Controller;

/**
 * @ClassName GreetingController
 * @Description
 * @Author Neil
 * @Date 2024/11/11 10:59
 * @Version V1.0
 **/
@Controller
public class QueryController {

    @QueryMapping
    public String greeting(@Argument String name) {
        return "Hello, " + name + "!";
    }

    @QueryMapping
    public Project project(@Argument String slug) {
        Project project = new Project();
        project.setSlug(slug);
        project.setName("holic-spring-graphql");
        project.setStatus(ProjectStatus.ACTIVE);

        User responsible = new User();
        responsible.setId("123");
        responsible.setCode("12345");
        responsible.setName("张三");
        responsible.setDepartment("IT");

        project.setResponsible(responsible);
        return project;
    }
}
